#!/usr/bin/env bash

source ./env


# 分发文件到其他 master
for NODE in "${!otherMaster[@]}"; do
    echo "--- $NODE ${MasterArray[$NODE]} ---"
    ssh ${otherMaster[$NODE]} "mkdir -p /etc/kubernetes/pki/etcd"
    scp /etc/kubernetes/pki/ca.* ${otherMaster[$NODE]}:/etc/kubernetes/pki/
    scp /etc/kubernetes/pki/sa.* ${otherMaster[$NODE]}:/etc/kubernetes/pki/
    scp /etc/kubernetes/pki/front-proxy-ca.* ${otherMaster[$NODE]}:/etc/kubernetes/pki/
    scp /etc/kubernetes/pki/etcd/ca.* ${otherMaster[$NODE]}:/etc/kubernetes/pki/etcd/
    scp /etc/kubernetes/admin.conf ${otherMaster[$NODE]}:/etc/kubernetes/
done